<?php
include "includes/uploader.class.php";
$uplObj= new post_upload();
if($_POST){
    $uplObj->inserta_imagenes();
}
?>
<!DOCTYPE HTML>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Prueba para subida de ficheros</title>
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
            <script src="js/jquery.uploadify.min.js" type="text/javascript"></script>
            <link rel="stylesheet" type="text/css" href="css/uploadify.css">
        </head>

        <body>
            <center>
                <br /><br /><br /><br /><br /><br />
                <h3>Formulario de subida de imagenes</h3>
                <form action="" name="formulario_de_subida" id="formulario_de_subida" method="post">
                    Nombre:<br />
                    <input type="text" name="nombre" />
                    <br /><br />
                    <p>Selecciona las imagenes o videos para subir.</p>
                    <div id="queue"></div>
                    <div>
                        <input id="file_upload" name="file_upload" type="file" multiple="true" />
                    </div>
                    <br /><br /><br />
                    <input type="hidden" name="nombre_imagen" id="nombre_imagen" value="" />
                    <input type="submit" value="SUBIR ARCHIVOS" />
                </form>
                <br /><br /><br />
                <?php
                echo $uplObj->printa_imagenes()
                ?>
                <script type="text/javascript">
                    <?php $timestamp = time();?>
                    $(function() {
                        $('#file_upload').uploadify({
                            'fileTypeDesc' : 'Image Files',
                            'fileTypeExts' : '*.gif; *.jpg; *.png; *.mov; *.avi',
                            'formData'     : {
                                'timestamp' : '<?php echo $timestamp;?>',
                                'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                            },
                            'removeCompleted' : false,
//                            'checkExisting' : 'includes/check-exists.php',
                            'swf'      : 'js/uploadify.swf',
                            'uploader' : 'includes/uploadify.php',
                            'onUploadError' : function(file, errorCode, errorMsg, errorString) {
//                                                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
                                                  alert('Ha habido un error subiendo el fichero'+file.name);
                                            },
                            'onUploadSuccess' : function(file, data, response) {
//                                alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
//                                alert('El fichero '+file.name+' se ha subido correctamenet');
                                tmp=$("#nombre_imagen").val()+file.name+";";
                                $("#nombre_imagen").val(tmp);
                                /*  
                                $.ajax({
                                        url: "http_call.php",
                                        data: $("#login").serialize()
                                }).done(function (obj){
                                    alert("El registro se ha grabado correct");
                                });
                                */
                            }
                        });
                    });
                </script>
            </center>
        </body>
    </html>